/**
 * 
 */
package beans;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.google.common.collect.Lists;

/**
 * @author Beanstao@gmail.com
 * @date 2013-10-6
 * @version 1.0
 */
public class ListComparable
{

	public static void main(String[] args)
	{
		List<Integer> a = Arrays.asList(1, 2, 3, 4);
		List<Integer> b = Arrays.asList(4, 3, 2, 1);
		System.out.println(compare(a, b));

		contains();
	}

	public static <T extends Comparable<T>> boolean compare(List<T> a, List<T> b)
	{
		if (a.size() != b.size())
			return false;
		Collections.sort(a);
		Collections.sort(b);
		for (int i = 0; i < a.size(); i++)
		{
			if (a.get(i) != b.get(i) && a.get(i).equals(b.get(i)))
				return false;
		}
		return true;
	}

	public static String a;

	public static void contains()
	{
		a = "hello a";
		List<String> t = Lists.newArrayList();
		t.add(a);
		a = "hello a";
		System.out.println(t.contains(a));
	}

}
